home *** CD-ROM | disk | FTP | other *** search
/ Hráč 2004 August / Hrac_72_2004-08_dvd.iso / dema / Rapid Gun / rg_setup.exe / common / text_cdiffuse.fx < prev    next >
Text File  |  2004-04-21  |  4KB  |  132 lines

  1. // LF2 Engine
  2. // (C) 2002-3 7FX
  3. //---------------------------------------------------------------------------
  4. // Simple font effect with diffuse color only
  5. //---------------------------------------------------------------------------
  6. #include "common.fxh"
  7. //---------------------------------------------------------------------------
  8. // Common parameters
  9. // Desc
  10. string desc : Description = "Shader pro texty, textura a konstantni barva, blenduje se na pozadi.";
  11. // Requirements
  12. string req : Requirements = "Diffuse";
  13. // vertex format needed for all techniques 
  14. string vf : VertexFormat = "POSITION | FONTMAP"; // 129 (for export) 
  15. //---------------------------------------------------------------------------
  16. // WVP matrix
  17. const matrix cMtxWVP : WorldViewProjection;
  18. // Diffuse font color, default white
  19. const float4 cDiffuse : DIFFUSE = {1.0f, 1.0f, 1.0f, 1.0f};
  20. // Matrices for fixed function technique
  21. const matrix cMtxW : World;
  22. // Sampler filters
  23. DECLARE_TEX_SAMPLER_VALUES;
  24. //---------------------------------------------------------------------------
  25. // Font texture
  26. texture fonttex : FONTMAP;
  27. //---------------------------------------------------------------------------
  28. // Sampler for font texture
  29. sampler font_sampler = sampler_state
  30. {
  31.     Texture = <fonttex>;
  32.     SET_TEX_SAMPLER_FILTERS;
  33.     AddressU = CLAMP;
  34.     AddressV = CLAMP;
  35. }; 
  36. //---------------------------------------------------------------------------
  37. // programs
  38. struct VS_OUTPUT
  39. {
  40.     float4 Position : POSITION;
  41.     float2 FontMapCoord : TEXCOORD0;
  42. };
  43.  
  44. // vertex shader
  45. VS_OUTPUT VS(float4 Position : POSITION, float2 FontMapCoord : TEXCOORD0)
  46. {
  47.     VS_OUTPUT Out = (VS_OUTPUT)0;
  48.     Out.Position = mul(Position, cMtxWVP);
  49.     Out.FontMapCoord = FontMapCoord;
  50.     return Out;
  51. }
  52.  
  53. // pixel shader
  54. float4 PS(VS_OUTPUT In) : COLOR
  55. {
  56.     return cDiffuse * tex2D(font_sampler, In.FontMapCoord);
  57. }
  58.  
  59. //---------------------------------------------------------------------------
  60. technique vs11_ps11
  61. <
  62.     // technique streams
  63.     string stream1 = "POSITION | FONTMAP";
  64. >
  65. {
  66.     pass p0
  67.     <
  68.         // pass stream mapping
  69.         string streammap = "stream1";
  70.     >
  71.     {
  72.         AlphaRef = 0x08;
  73.         VertexShader = compile vs_1_1 VS();
  74.         PixelShader  = compile ps_1_1 PS();
  75.     }
  76. }
  77. //---------------------------------------------------------------------------
  78. technique vs11_ps0
  79. <
  80.     string stream1 = "POSITION | FONTMAP";
  81. >
  82. {
  83.     pass p0
  84.     <
  85.         string streammap = "stream1";
  86.     >
  87.     {
  88.         AlphaRef = 0x08;
  89.     
  90.         TextureFactor = <cDiffuse>;
  91.         
  92.         VertexShader = compile vs_1_1 VS();
  93.         
  94.         Sampler[0]   = <font_sampler>;
  95.         ColorOp[0]   = Modulate;
  96.         ColorArg1[0] = Texture;
  97.         ColorArg2[0] = TFactor;
  98.         AlphaOp[0]   = Modulate;
  99.         AlphaArg1[0] = Texture;
  100.         AlphaArg2[0] = TFactor;
  101.     }
  102. }
  103. //---------------------------------------------------------------------------
  104. technique vs0_ps0
  105. <
  106.     string stream1 = "POSITION | FONTMAP";
  107. >
  108. {
  109.     pass p0
  110.     <
  111.         string streammap = "stream1";
  112.     >
  113.     {
  114.         AlphaRef = 0x08;
  115.     
  116.         // matrices
  117.         WorldTransform[0] = <cMtxW>;
  118.     
  119.         TextureFactor = <cDiffuse>;
  120.         
  121.         Sampler[0]   = <font_sampler>;
  122.         ColorOp[0]   = Modulate;
  123.         ColorArg1[0] = Texture;
  124.         ColorArg2[0] = TFactor;
  125.         AlphaOp[0]   = Modulate;
  126.         AlphaArg1[0] = Texture;
  127.         AlphaArg2[0] = TFactor;
  128.     }
  129. }
  130. //---------------------------------------------------------------------------
  131.  
  132.